package com.mtr.databoard.domain.components;

import com.mtr.databoard.domain.Entity;
import com.mtr.databoard.domain.components.CustomerOptions;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Component
public class ViewComponent extends Entity<UUID> implements Cloneable {
    public ViewComponent() {
        this.setId(UUID.randomUUID());
    }

    public ViewComponent(String name) {
        this.name = name;
        this.setId(UUID.randomUUID());
        this.updateTime = new Date();
    }

    private ViewResource cover;
    private String name;
    private String code;
    private String description;
    private Size size;
    private List<ViewResource> resources;
    private String headLinks;
    private String codes;
    private Date updateTime;
    private String htmlbody;
    private CustomerOptions customerOptions;

    public CustomerOptions getCustomerOptions() {
        return customerOptions;
    }
    public void setCustomerOptions(CustomerOptions customerOptions) {
        this.customerOptions = customerOptions;
    }

    public String getHtmlbody() {
        return htmlbody;
    }

    public void setHtmlbody(String htmlbody) {
        this.htmlbody = htmlbody;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Size getSize() {
        return size;
    }

    public void setSize(Size size) {
        this.size = size;
    }

    public String getHeadLinks() {
        return headLinks;
    }

    public void setHeadLinks(String headLinks) {
        this.headLinks = headLinks;
    }

    public String getCodes() {
        return codes;
    }

    public void setCodes(String codes) {
        this.codes = codes;
    }

    public ViewResource getCover() {
        return cover;
    }

    public void setCover(ViewResource cover) {
        this.cover = cover;
    }

    public List<ViewResource> getResources() {
        return resources;
    }

    public void setResources(List<ViewResource> resources) {
        this.resources = resources;
    }

    public void update(ViewResource cover, String name, String code, String description, Size size, List<ViewResource> resources, String headLinks, String codes,String htmlbody,CustomerOptions customerOptions) {
        this.cover = cover;
        this.name = name;
        this.code = code;
        this.description = description;
        this.size = size;
        this.resources = resources;
        this.headLinks = headLinks;
        this.codes = codes;
        this.updateTime = new Date();
        this.htmlbody=htmlbody;
        this.customerOptions=customerOptions;
    }


    /**
     * 复制
     * @return
     * @throws CloneNotSupportedException
     */
    public ViewComponent copy() throws CloneNotSupportedException {
        ViewComponent component=(ViewComponent)this.clone();
        component.setId(UUID.randomUUID());
        return component;
    }
}
